.class public Lorg/microemu/app/util/MidletURLReference;
.super Ljava/lang/Object;
.source "MidletURLReference.java"

# interfaces
.implements Lorg/microemu/app/util/XMLItem;


# instance fields
.field private name:Ljava/lang/String;

.field private url:Ljava/lang/String;


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 50
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 51
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;)V
    .locals 0
    .parameter "name"
    .parameter "url"

    .prologue
    .line 58
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 59
    iput-object p1, p0, Lorg/microemu/app/util/MidletURLReference;->name:Ljava/lang/String;

    .line 60
    iput-object p2, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    .line 61
    return-void
.end method


# virtual methods
.method public equals(Ljava/lang/Object;)Z
    .locals 2
    .parameter "obj"

    .prologue
    .line 64
    instance-of v0, p1, Lorg/microemu/app/util/MidletURLReference;

    if-nez v0, :cond_0

    .line 65
    const/4 v0, 0x0

    .line 67
    .end local p1
    :goto_0
    return v0

    .restart local p1
    :cond_0
    check-cast p1, Lorg/microemu/app/util/MidletURLReference;

    .end local p1
    iget-object v0, p1, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    iget-object v1, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    goto :goto_0
.end method

.method public getName()Ljava/lang/String;
    .locals 1

    .prologue
    .line 126
    iget-object v0, p0, Lorg/microemu/app/util/MidletURLReference;->name:Ljava/lang/String;

    return-object v0
.end method

.method public getUrl()Ljava/lang/String;
    .locals 1

    .prologue
    .line 130
    iget-object v0, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    return-object v0
.end method

.method public read(Lnanoxml/XMLElement;)V
    .locals 3
    .parameter "xml"

    .prologue
    const-string v2, ""

    .line 115
    const-string v0, "name"

    const-string v1, ""

    invoke-virtual {p1, v0, v2}, Lnanoxml/XMLElement;->getChildString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lorg/microemu/app/util/MidletURLReference;->name:Ljava/lang/String;

    .line 116
    const-string v0, "url"

    const-string v1, ""

    invoke-virtual {p1, v0, v2}, Lnanoxml/XMLElement;->getChildString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    .line 117
    return-void
.end method

.method public save(Lnanoxml/XMLElement;)V
    .locals 2
    .parameter "xml"

    .prologue
    .line 120
    invoke-virtual {p1}, Lnanoxml/XMLElement;->removeChildren()V

    .line 121
    const-string v0, "name"

    iget-object v1, p0, Lorg/microemu/app/util/MidletURLReference;->name:Ljava/lang/String;

    invoke-virtual {p1, v0, v1}, Lnanoxml/XMLElement;->addChild(Ljava/lang/String;Ljava/lang/String;)Lnanoxml/XMLElement;

    .line 122
    const-string v0, "url"

    iget-object v1, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    invoke-virtual {p1, v0, v1}, Lnanoxml/XMLElement;->addChild(Ljava/lang/String;Ljava/lang/String;)Lnanoxml/XMLElement;

    .line 123
    return-void
.end method

.method public toString()Ljava/lang/String;
    .locals 10

    .prologue
    const-string v9, "/"

    .line 74
    :try_start_0
    new-instance v6, Ljava/net/URL;

    iget-object v7, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    invoke-direct {v6, v7}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_0

    .line 79
    .local v6, u:Ljava/net/URL;
    new-instance v0, Ljava/lang/StringBuffer;

    invoke-direct {v0}, Ljava/lang/StringBuffer;-><init>()V

    .line 81
    .local v0, b:Ljava/lang/StringBuffer;
    invoke-virtual {v6}, Ljava/net/URL;->getProtocol()Ljava/lang/String;

    move-result-object v4

    .line 82
    .local v4, scheme:Ljava/lang/String;
    const-string v7, "file"

    invoke-virtual {v4, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-nez v7, :cond_0

    const-string v7, "http"

    invoke-virtual {v4, v7}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v7

    if-eqz v7, :cond_5

    .line 83
    :cond_0
    invoke-virtual {v0, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v7

    const-string v8, "://"

    invoke-virtual {v7, v8}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 84
    invoke-virtual {v6}, Ljava/net/URL;->getHost()Ljava/lang/String;

    move-result-object v7

    if-eqz v7, :cond_1

    .line 85
    invoke-virtual {v6}, Ljava/net/URL;->getHost()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 87
    :cond_1
    new-instance v2, Ljava/util/Vector;

    invoke-direct {v2}, Ljava/util/Vector;-><init>()V

    .line 88
    .local v2, pathComponents:Ljava/util/Vector;
    const-string v3, "/"

    .line 89
    .local v3, pathSeparator:Ljava/lang/String;
    new-instance v5, Ljava/util/StringTokenizer;

    invoke-virtual {v6}, Ljava/net/URL;->getPath()Ljava/lang/String;

    move-result-object v7

    const-string v8, "/"

    invoke-direct {v5, v7, v9}, Ljava/util/StringTokenizer;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 90
    .local v5, st:Ljava/util/StringTokenizer;
    :goto_0
    invoke-virtual {v5}, Ljava/util/StringTokenizer;->hasMoreTokens()Z

    move-result v7

    if-eqz v7, :cond_2

    .line 91
    invoke-virtual {v5}, Ljava/util/StringTokenizer;->nextToken()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v2, v7}, Ljava/util/Vector;->add(Ljava/lang/Object;)Z

    goto :goto_0

    .line 75
    .end local v6           #u:Ljava/net/URL;
    .end local v0           #b:Ljava/lang/StringBuffer;
    .end local v4           #scheme:Ljava/lang/String;
    .end local v2           #pathComponents:Ljava/util/Vector;
    .end local v3           #pathSeparator:Ljava/lang/String;
    .end local v5           #st:Ljava/util/StringTokenizer;
    :catch_0
    move-exception v7

    move-object v1, v7

    .line 76
    .local v1, e:Ljava/net/MalformedURLException;
    invoke-static {v1}, Lorg/microemu/log/Logger;->error(Ljava/lang/Throwable;)V

    .line 77
    iget-object v7, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    .line 111
    .end local v1           #e:Ljava/net/MalformedURLException;
    :goto_1
    return-object v7

    .line 93
    .restart local v0       #b:Ljava/lang/StringBuffer;
    .restart local v2       #pathComponents:Ljava/util/Vector;
    .restart local v3       #pathSeparator:Ljava/lang/String;
    .restart local v4       #scheme:Ljava/lang/String;
    .restart local v5       #st:Ljava/util/StringTokenizer;
    .restart local v6       #u:Ljava/net/URL;
    :cond_2
    invoke-virtual {v2}, Ljava/util/Vector;->size()I

    move-result v7

    const/4 v8, 0x3

    if-le v7, v8, :cond_4

    .line 94
    const-string v7, "/"

    invoke-virtual {v0, v9}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 95
    const/4 v7, 0x0

    invoke-virtual {v2, v7}, Ljava/util/Vector;->get(I)Ljava/lang/Object;

    move-result-object v7

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/Object;)Ljava/lang/StringBuffer;

    .line 96
    const-string v7, "/"

    invoke-virtual {v0, v9}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v7

    const-string v8, "..."

    invoke-virtual {v7, v8}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v7

    const-string v8, "/"

    invoke-virtual {v7, v9}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 97
    invoke-virtual {v2}, Ljava/util/Vector;->size()I

    move-result v7

    const/4 v8, 0x2

    sub-int/2addr v7, v8

    invoke-virtual {v2, v7}, Ljava/util/Vector;->get(I)Ljava/lang/Object;

    move-result-object v7

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/Object;)Ljava/lang/StringBuffer;

    .line 98
    const-string v7, "/"

    invoke-virtual {v0, v9}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 99
    invoke-virtual {v2}, Ljava/util/Vector;->size()I

    move-result v7

    const/4 v8, 0x1

    sub-int/2addr v7, v8

    invoke-virtual {v2, v7}, Ljava/util/Vector;->get(I)Ljava/lang/Object;

    move-result-object v7

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/Object;)Ljava/lang/StringBuffer;

    .line 107
    .end local v2           #pathComponents:Ljava/util/Vector;
    .end local v3           #pathSeparator:Ljava/lang/String;
    .end local v5           #st:Ljava/util/StringTokenizer;
    :goto_2
    iget-object v7, p0, Lorg/microemu/app/util/MidletURLReference;->name:Ljava/lang/String;

    if-eqz v7, :cond_3

    .line 108
    const-string v7, " - "

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 109
    iget-object v7, p0, Lorg/microemu/app/util/MidletURLReference;->name:Ljava/lang/String;

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 111
    :cond_3
    invoke-virtual {v0}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v7

    goto :goto_1

    .line 101
    .restart local v2       #pathComponents:Ljava/util/Vector;
    .restart local v3       #pathSeparator:Ljava/lang/String;
    .restart local v5       #st:Ljava/util/StringTokenizer;
    :cond_4
    invoke-virtual {v6}, Ljava/net/URL;->getPath()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    goto :goto_2

    .line 105
    .end local v2           #pathComponents:Ljava/util/Vector;
    .end local v3           #pathSeparator:Ljava/lang/String;
    .end local v5           #st:Ljava/util/StringTokenizer;
    :cond_5
    iget-object v7, p0, Lorg/microemu/app/util/MidletURLReference;->url:Ljava/lang/String;

    invoke-virtual {v0, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    goto :goto_2
.end method
